const log_config = require('../../server_config.json').log_config;
var log4js = require('log4js');

logger = log4js.getLogger();
logger.level = "error";
logger.debug("Some debug messages");

// 日志配置信息
log4js.configure({
    appenders: {
        "fileAppender": {
			"type": "dateFile",
			"numBackups": 30,
			"pattern": "yyyy-MM-dd",
			"filename": process.cwd() + log_config.filename,
			"layout": {
				"type": "pattern",
				"pattern": "%d [%p] [%c] - %m%n"
			}
		}
        // 作为本地输出
        // local_out: {
        //     type: 'stdout'
        // },
        // // 线上输出
        // everyday_file: {
        //     type: "dateFile",
        //     filename: process.cwd() + log_config.filename
        // },
    },
    categories: {
        "default": {
			"appenders": ["fileAppender"],
			"level": "info"
		}
        // default: { appenders: log_config.category, level: log_config.level, enableCallStack: log_config.enableCallStack },
    }
});

var logger = log4js.getLogger();

module.exports.logger = logger;